<?
include_once('../conn.php');
include_once('../include/func.php');
include("../user_check.php") ;


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CREATE ORDER</title>
<style>
.jc_lable1{
	width:120px; }
body,td,th {
	font-size: 12px;
	color: #333;
}
</style>

</head>

<body>

	<?
	
	if($_GET[action]==1){
	?>

<style>
.order_1 td{ border-bottom: #999 dotted 1px;}
</style>
<div style="width:700px;">

<form  name="order" method="post" action="" onSubmit="return CheckForm();">
<? $order = $db->select("SELECT * FROM `".tablepre."order` where `oid` = '".$_GET[oid]."'"); 
$checkmember[0][2]<>$order[0][1]?exit(ORDER_CAN_NOT_REVIEW):'';
?>
<img src="images/ttfjpg.php?t=<? echo ORDER_DETAILS;?>&amp;bg=titlebg2.jpg&amp;z=18&amp;x=5&amp;y=22&amp;r=0&amp;b=0&amp;g=0"  />
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr class="order_1">
    <td width="24%" align="right"><? echo ORDER_SN;?>：</td>
    <td width="26%"><? echo $order[0][4];?></td>
    <td width="20%" align="right"><? echo ORDER_DATE;?>：</td>
    <td width="30%"><? echo $order[0][11];?></td>
  </tr>
  <tr class="order_1">
    <td align="right"><? echo RECEIVER_NAME;?>：</td>
    <td><? echo $order[0][5];?></td>
    <td align="right"><? echo RECEIVER_TEL;?>：</td>
    <td><? echo $order[0][8];?>&nbsp;</td>
  </tr>
  <tr class="order_1">
    <td align="right"><? echo RECEIVER_MOB?>：</td>
    <td><? echo $order[0][6];?></td>
    <td align="right"><? echo RECEIVER_ZIP_CODE;?>：</td>
    <td><? echo $order[0][9];?></td>
  </tr>
  <tr class="order_1">
    <td align="right"><? echo RECEIVER_ADDRESS;?>：</td>
    <td colspan="3"><? echo $order[0][7];?></td>
  </tr>
  <tr class="order_1">
    <td align="right"><? echo RECEIVER_NOTE?>：</td>
    <td colspan="3"><? echo $order[0][10];?></td>
    </tr>
    
        <? if($order[0][13] >= 3){ ?>
    
      <tr>
          <td colspan="4"><img src="images/ttfjpg.php?t=<? echo ORDER_REFUND.' '.ORDER_REASON; ?>&amp;bg=titlebg2.jpg&amp;z=18&amp;x=5&amp;y=22&amp;r=0&amp;b=0&amp;g=0"  /></td>
      </tr>
      <tr class="order_1">
        <td align="right"><? echo ORDER_REFUND.' '.ORDER_REASON; ?>：</td>
        <td colspan="3"><? echo $order[0][19];?></td>
      </tr>
  <? } ?>

    <? if($order[0][13] >= 2){ ?>
          <tr class="order_1">
          <td colspan="4"><img src="images/ttfjpg.php?t=<? echo ORDER_EXPRESS; ?>&amp;bg=titlebg2.jpg&amp;z=18&amp;x=5&amp;y=22&amp;r=0&amp;b=0&amp;g=0"  /></td>
      </tr>
      <tr class="order_1">
    <td align="right"><? echo ORDER_EXPRESS;?>：</td>
    <td><? echo $order[0][2];?></td>
    <td align="right"><? echo ORDER_EXPRESS_SN;?>：</td>
    <td><? echo $order[0][3];?></td>
  </tr>
    
    
    <? }else{ ?>
  <? } ?>
  
</table>  
</form>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td colspan="8"><img src="images/ttfjpg.php?t=<? echo PRODUCT_DETAIL;?>&amp;bg=titlebg2.jpg&amp;z=18&amp;x=5&amp;y=22&amp;r=0&amp;b=0&amp;g=0"  /></td>
  </tr>  <?


	$array_stock = $db->select("SELECT * FROM `".tablepre."order_item` where `oid` = '".$_GET[oid]."' group by sid ");
	//print_r($array_stock);
	for($i=0;$i<count($array_stock);$i++){
  ?>
  <tr>
    <td colspan="8" bgcolor="#666666"><font color="#FFFFFF"><? echo stock($array_stock[$i][3],1); ?></font></td>
    </tr>
      <tr>
    <td colspan="8">
    <div style="border:#999 1px solid;">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="38%" rowspan="5" valign="top"><a href="<? echo pic_return(attachment(1,$array_stock[$i][3],'pic'));  ?>" target="_blank"><img src="<? echo pic_return(attachment(1,$array_stock[$i][3],'pic'));  ?>"  height="50" /></a></td>
          <td width="62%"><? echo PRODUCT_MODEL;?>：<? echo attachment(1,$array_stock[$i][3],'model');?></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><? echo PRODUCT_OTHER_LINK;?>：<? echo attachment(1,$array_stock[$i][3],'url')<>null?'<a href="'.attachment(1,$array_stock[$i][3],'url').'" target="_blank">'.MEMBER_WEB.'</a>':'';?></td>
        </tr>

      </table>
      </div>
      </td>
    </tr>
  <tr>
  <td><? echo PRODUCT_BATCH_NO;?></td>
    <td><? echo PRODUCT_MODEL;?></td>
    <td><? echo PRODUCT_QUANTITY;?></td>
    <td><? echo PRODUCT_MATERIAL;?></td>
    <td><? echo PRODUCT_COLOR;?></td>
    <td><? echo PRODUCT_SIZE;?></td>
    <td><? echo ORDER_UNIT_PRICE;?></td>
    <td><? echo PRODUCT_COUNT;?></td>
    
  </tr>
  <?
  $cart_item = $db->select("SELECT * FROM `".tablepre."order_item` where `sid` = '".$array_stock[$i][3]."'  and `oid` = '".$_GET[oid]."'");
 //print_r($cart_item);
  for($k=0;$k<count($cart_item);$k++){
	  $arr_list = $db->select("SELECT name,quality1,quality2,quality3,quantity,price,model,unit,iid,batch FROM `".tablepre."stock_item` where iid = '".$cart_item[$k][6]."' and sale = '1' ");
	 // print_r($arr_list);
	  /*
	  }
  $arr_list = $db->select("SELECT name,quality1,quality2,quality3,quantity,price,model,unit,iid FROM `".tablepre."stock_item` where sid = '".$array_stock[$i][0]."' and sale = '1' ");
		for($j=0;$j<count($arr_list);$j++) {*/ ?>
        <tr>
        <td><? echo $arr_list[0][9]; ?></td>
        <td><? echo $arr_list[0][6]==''?attachment(1,$array_stock[$i][3],model):$arr_list[0][6]; ?></td>
        <td><? echo $cart_item[0][4]; ?></td>
        <td><? echo $arr_list[0][3]; ?></td>
        <td><? echo $arr_list[0][1]; ?></td>
        <td><? echo $arr_list[0][2]; ?></td>
        <td><? echo unit(price_descount($checkmember[0][2],$arr_list[0][5])); ?></td>
        <td><? echo unit($cart_item[0][5]); ?></td>
        
        </tr>
  <?
  if($_POST){
	  $last_order_id = $db->select("SELECT oid FROM `".tablepre."order` order by oid desc limit 1");


	  
	  }
		}
		
		
  ?>
  
  
  <? }
  if($_POST){

	  	header("Location: pay.php?oid=".$last_order_id[0][0] );
	exit;
	  }
   ?>
     <tr >
    <td colspan="8"  bgcolor="#EEEEEE" ><div style="margin:5px; font-size:16px;"><? echo PRODUCT_TOTAL.': '.unit(order_total(1,$_GET[oid]));?>&nbsp; | &nbsp;<? echo PAY_ITEM_QUANTITY.'：'.order_total(2,$_GET[oid]);?></div></td>
    </tr>
</table>

</div>
<? }?><div id="print_button2" style="width:32px; height:32px;"><a href="include/user_print.php?action=order&oid=<? echo $_GET[oid];?>" target="_blank"><img src="images/print.png" /></a></div> 
</body>
</html>
